
/*
 * 简化版天气查询程序 - 不依赖外部库
 * 这个版本演示了基本的程序结构，但不包含实际的API调用
 * 适合学习C语言基础语法
 */

#include <stdio.h>
#include <string.h>

// 模拟天气数据结构
typedef struct {
    char city[50];
    float temperature;
    char description[50];
    int humidity;
} WeatherData;

// 模拟天气数据（实际应用中应从API获取）
WeatherData get_weather_data(const char* city) {
    WeatherData weather;
    strcpy(weather.city, city);
    
    // 简单的模拟数据
    if (strcmp(city, "beijing") == 0) {
        weather.temperature = 22.5;
        strcpy(weather.description, "晴天");
        weather.humidity = 45;
    } else if (strcmp(city, "shanghai") == 0) {
        weather.temperature = 26.8;
        strcpy(weather.description, "多云");
        weather.humidity = 68;
    } else if (strcmp(city, "guangzhou") == 0) {
        weather.temperature = 30.2;
        strcpy(weather.description, "小雨");
        weather.humidity = 85;
    } else {
        weather.temperature = 25.0;
        strcpy(weather.description, "未知");
        weather.humidity = 50;
    }
    
    return weather;
}

int main() {
    char city[50];
    
    printf("=== 天气查询程序 ===\n");
    printf("支持城市: beijing, shanghai, guangzhou\n");
    printf("请输入城市名称: ");
    scanf("%49s", city);
    
    // 获取天气数据
    WeatherData weather = get_weather_data(city);
    
    // 显示结果
    printf("\n=== 天气信息 ===\n");
    printf("城市: %s\n", weather.city);
    printf("温度: %.1f°C\n", weather.temperature);
    printf("天气: %s\n", weather.description);
    printf("湿度: %d%%\n", weather.humidity);
    printf("================\n");
    
    return 0;
}
